<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_name" data-rule="required" class="form-control form-control" name="row[agent_name]" type="text" value="{$row.agent_name}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_phone')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_phone" data-rule="required" class="form-control form-control" name="row[agent_phone]" type="text" value="{$row.agent_phone}">
        </div>
    </div>
     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">密码:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-password"  class="form-control " name="row[password]" type="password">
        </div>
    </div>
     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Branch_office')}:</label>
        <div class="col-xs-12 col-sm-8">
             {:build_radios('row[branch_office]', ['1'=>__('Branch_office 1'), '2'=>__('Branch_office 2')],$row.branch_office)}
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Addre')}:</label>
        <div class="col-xs-12 col-sm-8">
          {:Form::cxselect('ajax/area', ['province','city','area'], ['province'=>$row.province, 'city'=>$row.city,'area'=>$row.area])}
        </div>
    </div>
 

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_region')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_region" class="form-control form-control" name="row[agent_region]" type="text" value="{$row.agent_region}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Term_start')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-term_start" class="form-control datetimepicker form-control" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[term_start]" type="text" value="{$row.term_start|datetime}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Term_end')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-term_end" class="form-control datetimepicker form-control" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[term_end]" type="text" value="{$row.term_end|datetime}">
        </div>
    </div>
     <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Send_country')}:</label>
        <div class="col-xs-12 col-sm-8">
             {:build_radios('row[send_country]', ['1'=>__('Send_country 1'), '2'=>__('Send_country 2')],$row.send_country)}
        </div>
    </div> 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address"  class="form-control form-control" name="row[address]" type="text" value="{$row.address}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_code')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_code" class="form-control form-control" name="row[agent_code]" type="number" value="{$row.agent_code}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_contact')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_contact" class="form-control form-control" name="row[agent_contact]" type="text" value="{$row.agent_contact}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_tel')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_tel" class="form-control form-control" name="row[agent_tel]" type="text" value="{$row.agent_tel}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Agent_fax')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-agent_fax" class="form-control form-control" name="row[agent_fax]" type="text" value="{$row.agent_fax}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Clerk')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-clerk"   data-source="/api/base/user" data-primary-key="userid" data-field="username"  data-params='{"custom[id]":"1"}'  class="form-control selectpage" name="row[clerk]" type="text" value="{$row.clerk}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Docking')}:</label>
        <div class="col-xs-12 col-sm-8">
          <input id="c-docking"  data-source="/api/base/user" data-primary-key="userid" data-field="username"  data-params='{"custom[id]":"1"}'  class="form-control selectpage" name="row[docking]" type="text" value="{$row.docking}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bond_amount')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bond_amount" data-rule="required" class="form-control form-control" step="0.01" name="row[bond_amount]" type="number" value="{$row.bond_amount}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Deduction_amount')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-deduction_amount" data-rule="required" class="form-control form-control" step="0.01" name="row[deduction_amount]" type="number" value="{$row.deduction_amount}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Finance_invoice')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_invoice" class="form-control form-control" name="row[finance_invoice]" type="text" value="{$row.finance_invoice}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Finance_taxnumber')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_taxnumber" class="form-control form-control" name="row[finance_taxnumber]" type="text" value="{$row.finance_taxnumber}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Account_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-account_name" class="form-control form-control" name="row[account_name]" type="text" value="{$row.account_name}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Account_bank')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-account_bank" class="form-control form-control" name="row[account_bank]" type="text" value="{$row.account_bank}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Bank_number')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-bank_number" class="form-control form-control" name="row[bank_number]" type="text" value="{$row.bank_number}">
        </div>
    </div>
    <div class="form-group row">
        <label class="control-label col-xs-12 col-sm-2">{:__('产品折扣')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-template="eventtpl" data-name="row[discount_array]">
                <dd><ins>{:__('产品')}</ins><ins>{:__('单位')}</ins><ins>{:__('折扣(10-100)')}</ins></dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" id="add-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <!--请注意 dd和textarea间不能存在其它任何元素，实际开发中textarea应该添加个hidden进行隐藏-->
                <textarea name="row[discount_array]" class="form-control hidden" cols="30" rows="5">{$row['discount_array']}</textarea>
            </dl>
            <script id="eventtpl" type="text/html">
                <dd class="form-inline">
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][id]" class="form-control selectpage" data-source="ajax/product"  data-field="name" value="<%=row.id%>" placeholder="产品" size="10"/>
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][dw]" class="form-control selectpage" data-source="ajax/dw"   data-field="name"  value="<%=row.dw%>" placeholder="单位"/>
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][discount]" class="form-control" value="<%=row.discount%>" placeholder="折扣"/>
                    </ins>
                    <!--下面的两个按钮务必保留-->
                    <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
                    <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
                </dd>
            </script>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('往来单位编码')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-finance_code" class="form-control form-control" name="row[finance_code]" type="text" value="{$row.finance_code}">
        </div>
    </div>
    <div class=" panel panel-default" style="text-align: center;height: 500px;width: 66%;margin-left: 17%;">
    <div class="panel-heading" style="height: 7%">
        <h3 class="panel-title">
            代理商产品折扣
        </h3>
    </div>
      <div class="fixed-table-body panel-body" style="height: 93%">
         <dl class="fieldlist" id="fieldlist" data-index="1">
              <dd id="bappend"><a href="javascript:;" class="btn btn-sm btn-success" id="append"><i class="fa fa-plus"></i>       {:__('Append')}</a></dd>
              <dd>
                    <ins>分类</ins>
                    <ins>折扣(1-10)</ins>
                  
                </dd>
                {foreach name="cate_info" item="va" key="k" }
            
                      <dd class="form-inline <?php if(!in_array($k,$row['product_discount_key']))echo 'hidden';?>">
                        <select  id="selet_{$k}"   class="form-control selet"  name="product_discount[{$k}][id]">
                            <option value="0">请选择</option>
                            {foreach name="cate_info" item="vo" key="key"}
                       
                            <option <?php if($row['product_discount'] && array_key_exists($k,$row['product_discount']) && $row['product_discount'][$k]['id'] == $vo['id']) echo 'selected';?> value="{$vo['id']}">{$vo['name']}</option>
                            {/foreach}
                        </select>
                        
                        <input id="c-product_discount{$va['id']}" data-rule="range(1~10)" min="1" max="10" class="form-control form-control" name="product_discount[{$k}][discount]" type="number" value="<?php echo isset($row['product_discount'][$k]['discount'])?$row['product_discount'][$k]['discount']:10;?>" size="10">
                        <span class="btn btn-sm btn-danger btn-removes"><i class="fa fa-times"></i></span>
                    </dd>
               {/foreach}
                   


                </dl>
        
        </div>
    </div>
    <div class="form-group row">
        <label class="control-label col-xs-12 col-sm-2">{:__('Excel模板导入')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-template="eventtpl2"  data-name="row[excle_array]">
                <dd><ins>{:__('数据字段')}</ins><ins>{:__('Excle标题')}</ins></ins></dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" id="excel-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <!--请注意 dd和textarea间不能存在其它任何元素，实际开发中textarea应该添加个hidden进行隐藏-->
                <textarea name="row[excle_array]" class="form-control hidden" cols="30" rows="5">{$row['excle_array']}</textarea>
            </dl>
            <script id="eventtpl2" type="text/html">
                <dd class="form-inline">
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][key]" class="form-control"  value="<%=row.key%>"/>
                    </ins>
                    <ins>
                        <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>"/>
                    </ins>
                    <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span>
                </dd>
            </script>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
